<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/9
 * Time: 10:24
 */
$conn = new mysqli();
$conn->connect('127.0.0.1','root','root','bank');
if (!empty($conn->connect_error)){
    echo 'mysql数据库连接失败'.$conn->connect_error;
}
else{
    echo '连接成功';
}

$userNo = '6225098134285';
$userPwd = '21218cca77804d2ba1922c33e0151105';

//where CardNO = '.$userNo.' and CardPwd = '.$userPwd.'.
$result = $conn->query("select * from bankcard ");
$result;

//$row = $result->fetch_assoc();
//
//echo $row['CardNo'];
//$data=[];

while(true){
    $row = $result->fetch_assoc();
    if (empty($row)){
        echo '结束';
        break;
    }
//    print_r($row);
//    echo $row['CardNo'];
    $data[]=$row;
}
$ac_id = '';
for ($i = 0 ; $i<count($data);$i++){
    if ($data[$i]['CardNo']==$userNo && $data[$i]['CardPwd']==$userPwd){
        echo '登入成功';
        $ac_id = $data[$i]['AccountId'];
        break;
    }
}
echo $ac_id;


$userRealName = '';
$result1 = $conn->query("select * from accountinfo where AccountId = ".$ac_id);

$row = $result1->fetch_assoc();

$userRealName = $row['RealName'];
echo $userRealName;